package highscore;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JFrame;
import ui.BoxStyle;
import ui.Collumn;
import ui.Playlist;
import utils.KeyListFactory;

/**
 * @author duncan
 */
public class HighscoreWindow extends JFrame
{
    //The playlist component used to show the list.
    Playlist list	= new Playlist();
    Collumn c_user	= new Collumn("    Namn    ");
    Collumn c_score	= new Collumn("Score");
    Collumn c_level	= new Collumn("Level");
    Collumn c_date	= new Collumn("    Date    ");
    String[] headers	= {"    Namn    ", "Score", "Level", "    Date    "};
    

    //The highscore object that holds all the data.
    Highscore highscore;
    KeyListFactory factory = new KeyListFactory();

    /**
     * HighscoreWindow constructor.
     */
    public HighscoreWindow()
    {
		this (new Highscore());
    }

    /**
     * HighscoreWindow constructor.
     *
     * @param highscore The highscore component to show in the list.
     */
    public HighscoreWindow(Highscore highscore)
    {
		this.highscore = highscore;

		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(640, 640);
		setVisible(true);
		setLayout(new BorderLayout());
		add(BorderLayout.CENTER, list);

		list.setBackground(new Color(20, 20, 20));
		list.addHeader(c_user);
		list.addHeader(c_score);
		list.addHeader(c_level);
		list.addHeader(c_date);

		for (int i = 0; i < highscore.getRowCount(); i++)
		{
			list.addItem(factory.create(headers, new String[]
			{
			highscore.getRowAt(i).name + "",
			highscore.getRowAt(i).score + "",
			highscore.getRowAt(i).level + "",
			highscore.getRowAt(i).date + "",
			}), i);
		}

		list.setFunctionsOff(true);						//Ordering and DragNadDrop should be turned off.
		list.setStyleItemsLight(new BoxStyle(new Color(80, 80, 80), new Color(224, 127, 0), Color.BLACK, Color.BLACK, new Font("Serif", Font.PLAIN, 10)));
    }
}
